package com.google.persist;

import org.hibernate.EmptyInterceptor;
import org.springframework.stereotype.Component;


@Component
public class Interceptor extends EmptyInterceptor {
    private String targetTableName;// 目标母表名
    private String tempTableName;// 操作子表名

    public Interceptor() {}

    public String onPrepareStatement(String sql) {
        sql = sql.replaceAll(targetTableName, tempTableName);
        return sql;

    }

    public String getTargetTableName() {
        return targetTableName;
    }

    public void setTargetTableName(String targetTableName) {
        this.targetTableName = targetTableName;
    }

    public String getTempTableName() {
        return tempTableName;
    }

    public void setTempTableName(String tempTableName) {
        this.tempTableName = tempTableName;
    }
}
